fold

inline fun <L, R, O> Either<L, R>.fold(ifLeft: (L) -> O, ifRight: (R) -> O): O(source)


inline fun <T, R> KOptional<T>.fold(ifPresent: (T) -> R, ifEmpty: () -> R): R(source)

Transforms the value with the ifPresent function if it's present, or the one provided by ifEmpty otherwise.